package com.arina.onepagesmarthome;

import java.util.ArrayList;
import java.util.Iterator;

import android.view.View;
import android.widget.Button;

public class macro {
	public macro(ArrayList<ElectrictCommand> macros) {
		super();
		this.macros = macros;
	}

	public ArrayList<ElectrictCommand> macros;
	public ArrayList<Button> buttons;

	private void runMacro()
	{
		for(Iterator<ElectrictCommand> i=macros.iterator();i.hasNext();)
		{
			i.next().sendCommand();
		}
	}
	
	public void setOnClickListener()
	{
		for(Iterator<Button> i=buttons.iterator();i.hasNext();)
		{
			i.next().setOnClickListener(new View.OnClickListener() {

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					runMacro();
				}
			});
		}
	}
}
